<template>
	<view>
		<scroll-view scroll-y="true" class="content" :enhanced="true" :bounces="false" :show-scrollbar="false">
			<view class="index pt10">
				<diy :diyItems="data" :bannerList="bannerList" :hotProductList="hotProductList"
					:homeProductList="homeProductList">
				</diy>

				<!-- <view style="width: 100%;height: calc(120rpx + env(safe-area-inset-bottom) / 2);"></view> -->
				<!-- <tab-bar-view :tabCode="'0'"></tab-bar-view> -->
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import diy from '@/components/diy/diy.vue';
	import {
		queryListByApp,
		queryHotProductListByApp,
		queryHomeProductListByApp
	} from "@/api/index.js"

	export default {
		components: {
			diy
		},
		onLoad() {
			// this.queryListByApp()
			// this.queryHotProductListByApp()
		},
		onShow() {
			// this.userInfo = uni.getStorageSync('userInfo')
			this.queryListByApp()
			this.queryHotProductListByApp()
			this.queryHomeProductListByApp()
		},
		onReady() {
			// 隐藏导航栏
			// uni.hideTabBar({});
		},
		data() {
			return {
				bannerList: [],
				hotProductList: [],
				homeProductList: [],
			};
		},
		onPullDownRefresh() {
			/*下拉到顶，页面值还原初始化*/
			// this.queryListByApp()
			// this.queryHotProductListByApp()
			// this.queryHomeProductListByApp()

			// setTimeout(function() {
			// 	uni.stopPullDownRefresh();
			// }, 1500);
		},
		onPageScroll: function(e) {
			if (e.scrollTop < 0) {
				wx.pageScrollTo({
					scrollTop: 0
				})
			}
		},
		methods: {
			//  banner列表
			queryListByApp() {
				queryListByApp().then(res => {
					this.bannerList = res.object
				})
			},
			// 平台爆款列表
			queryHotProductListByApp() {
				queryHotProductListByApp().then(res => {
					this.hotProductList = res.object
				})
			},

			// 平台商品列表
			queryHomeProductListByApp() {
				queryHomeProductListByApp().then(res => {
					this.homeProductList = res.object
				})
			},

			goPage(url) {
				uni.navigateTo({
					url
				});
			},

			goPageUserManual(url) {
				uni.navigateTo({
					url: "/pages/my/userManual/userManual"
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	.content {
		//可视高度，需要在多大的盒子中进行滑动
		height: 100vh;
		width: 100%;
	}

	.index {
		background-color: #f5f5f5;
	}
</style>